package simulacionproyecto;

public class RandomGenerator {
    
    private int _varP;
    private int _varC;
    private int _varA;
    private int _varXi;
    public int _varM;
        
    public RandomGenerator() {
        super();
    }
    
    public double[] getRandomNumber(int varP, int varC, int varA, int varXi){
        
        double[] numbers = new double[30];
        
        int m = calcularM(varP);
        int Xi = varXi;
        int aXi_c = (varA*varXi)+varC;
        int aXi_c_modm = (aXi_c)%m;
        
        for(int i=0; i<numbers.length; i++){
            //System.out.println("numeroAleatorio es: "+Xi);
            Xi = aXi_c_modm;
            aXi_c = (varA*Xi)+varC;
            aXi_c_modm = (aXi_c)%m;
            numbers[i] = Xi;
            
         }
        
        return numbers;
        
    }
    
    public int calcularM(int varP){
        int m = 1;
        while(m<varP){
            m = m*2;
        }
        return m;
    }
    
}
